-- -------------------------------------------------------------------------
-- Data/heist.lua
-- Heist Tool Data Definitions
-- Purpose: Centralized data for all heist operations
-- Maintenance: Update offsets/values here when game updates
-- -------------------------------------------------------------------------

local heist = {}

-- -------------------------------------------------------------------------
-- [Script Names]
-- -------------------------------------------------------------------------

heist.SCRIPTS = {
    LAUNCHER = "fmmc_launcher",
    MISSION_OLD = "fm_mission_controller",
    MISSION_NEW = "fm_mission_controller_2020",
    ISLAND_HEIST = "fm_content_island_heist",
    ISLAND_PLANNING = "heist_island_planning",
    CASINO_PLANNING = "gb_casino_heist_planning",
    GANG_OPS_PLANNING = "gb_gang_ops_planning",
    TUNER_PLANNING = "tuner_planning",
    SALVAGE_PLANNING = "vehrob_planning",
    SECURITY_CONTRACT = "fm_content_security_contract",
    -- Salvage Yard missions
    VEHROB_CARGO = "fm_content_vehrob_cargo_ship",
    VEHROB_POLICE = "fm_content_vehrob_police",
    VEHROB_ARENA = "fm_content_vehrob_arena",
    VEHROB_CASINO = "fm_content_vehrob_casino_prize",
    VEHROB_SUBMARINE = "fm_content_vehrob_submarine",
    -- Cluckin Bell
    CIRCUIT_HACK = "circuitblockhack",
    WORD_HACK = "word_hack",
}

-- -------------------------------------------------------------------------
-- [Global Variable Offsets]
-- -------------------------------------------------------------------------

heist.GLOBALS = {
    -- Launcher
    LAUNCHER = {
        BASE_LOBBY = 794954,
        -- Step globals (indexes)
        STEP_1 = 4718592 + 3539,
        STEP_2 = 4718592 + 3540,
        STEP_3 = 4718592 + 3542 + 1,
        STEP_4 = 4718592 + 192451 + 1,
        STEP_5 = 4718592 + 3536,
        DIFFICULTY = 4718592 + 3538,
        -- Step values for different scenarios
        SOLO_VALUES = {
            STEP_1 = 1,
            STEP_2 = 1,
            STEP_3 = 1,
            STEP_4 = 0,
            STEP_5 = 1,
        },
        APARTMENT_RESET = {
            STEP_3 = 1,
            STEP_4 = 0,
            STEP_5 = 1,
        },
        CASINO_RESET = {
            STEP_1 = 1,
            STEP_2 = 1,
            STEP_3 = 2,
            STEP_4 = 11,
        },
        DOOMSDAY_RESET = {
            STEP_1 = 1,
            STEP_2 = 1,
            STEP_3 = 2,
            STEP_4 = 11,
        },
        -- Player count values
        PLAYER_COUNT = {
            SOLO = 1,
            DUO = 2,
            FLEECA = 2,        -- Fleeca Job requires 2 players
            APARTMENT = 4,     -- Other apartment heists require 4 players
        },
    },

    -- Heist Cuts Base
    CUTS = {
        CASINO = {
            PLAYER1 = 1973231 + 1497 + 736 + 92 + 1,
            PLAYER2 = 1973231 + 1497 + 736 + 92 + 2,
            PLAYER3 = 1973231 + 1497 + 736 + 92 + 3,
            PLAYER4 = 1973231 + 1497 + 736 + 92 + 4,
        },
        CAYO = {
            PLAYER1 = 1980035 + 831 + 56 + 1,
            PLAYER2 = 1980035 + 831 + 56 + 2,
            PLAYER3 = 1980035 + 831 + 56 + 3,
            PLAYER4 = 1980035 + 831 + 56 + 4,
        },
        DOOMSDAY = {
            PLAYER1 = 1968543 + 812 + 50 + 1,
            PLAYER2 = 1968543 + 812 + 50 + 2,
            PLAYER3 = 1968543 + 812 + 50 + 3,
            PLAYER4 = 1968543 + 812 + 50 + 4,
        },
        APARTMENT = 1936013,
        APARTMENT_LOCAL = 1937981 + 3008 + 1,
        GENERIC = 2686095 + 6783,
    },

    -- Apartment
    APARTMENT = {
        RELOAD = 1936048,
        -- Cooldown: 1877303 + 1 + (PLAYER_ID * 77) + 76 (需要动态计算)
    },

    -- Casino
    CASINO = {
        DATA_BASE = 1973197,
        FINALE_CHECK = 2685153 + 21,
        CHIPS_BONUS = 1972794,
        -- Casino Heist Data (base 1973197)
        DATA = {
            TARGET = 1973198,
            CAMERAS = 1973199,   -- bool
            PATROL = 1973200,    -- bool
            GUARDS = 1973201,
            NVDS = 1973202,      -- bool
            DRILLS = 1973203,    -- bool
            BUYER = 1973205,
            DECOY = 1973207,     -- bool
            GETAWAY = 1973208,
            GUNMAN = 1973210,
            WEAPONS = 1973211,
            DRIVER = 1973212,
            VEHICLES = 1973213,
            HACKER = 1973214,
            KEYCARDS = 1973215,
            EXIT = 1973217,
            MASKS = 1973218,
            VAN = 1973219,
            INFESTED = 1973221,  -- bool
            BITSET = 1973222,
            GEAR = 1973223,      -- bool
            HARDMODE = 1973224,  -- bool
        },
        -- Casino finale setup values
        FINALE_VALUES = {
            VAN_BIG_CON = 3,  -- Van type for Big Con approach
        },
    },

    -- Doomsday Ready States
    DOOMSDAY_READY = {
        PLAYER1 = 1882717 + 1 + (0 * 315) + 43 + 11 + 1,
        PLAYER2 = 1882717 + 1 + (1 * 315) + 43 + 11 + 2,
        PLAYER3 = 1882717 + 1 + (2 * 315) + 43 + 11 + 3,
        PLAYER4 = 1882717 + 1 + (3 * 315) + 43 + 11 + 4,
    },

    -- Cayo Ready
    CAYO_READY_BASE = 1981147,
    CAYO_READY = {
        PLAYER1 = 1981156,
        PLAYER2 = 1981184,
        PLAYER3 = 1981211,
        PLAYER4 = 1981238,
    },

    -- Casino Ready
    CASINO_READY_BASE = 1977594,
    CASINO_READY = {
        PLAYER1 = 1977603,
        PLAYER2 = 1977672,
        PLAYER3 = 1977740,
        PLAYER4 = 1977808,
    },

    -- Apartment Ready
    APARTMENT_READY_BASE = 2658294,
    APARTMENT_READY = {
        PLAYER1 = 2658565,
        PLAYER2 = 2659033,
        PLAYER3 = 2659501,
        PLAYER4 = 2659969,
    },

    -- Classic Heist
    CLASSIC_HEIST = {
        BOARD = 1936048,
        COOLDOWN_BASE = 1877303,
    },

    -- Agency Payout
    AGENCY_PAYOUT = 262145 + 31249,

    -- Character Index
    CHARACTER_INDEX = 1574927,

    -- GTA Plus
    GTA_PLUS = 1970058,

    -- VIP Work
    VIP_WORK = {
        BASE = 1950714,
        SIGHTSEER = {
            COOLDOWN = 12960,
            TIMER = 12961,
            PAYOUT_BASE = 12963,
            PAYOUT_MULTIPLIER = 12968,
            PAYOUT_MIN = 12964,
            PAYOUT_MIN_MULTIPLIER = 12969,
        },
        FORTIFIED = {
            COOLDOWN = 19229,
            START = 19226,
            TIMER = 19227,
            PAYOUT = 19230,
        },
    },

    -- Payphone
    PAYPHONE = {
        COOLDOWN = 262145 + 31283,
        SECURITY_COOLDOWN = 262145 + 31203,
    },

    -- Business
    BUSINESS = {
        BUNKER_PROD_TRIGGER1 = 2708925 + 1 + 5 * 2,
        BUNKER_PROD_TRIGGER2 = 2708925 + 1 + 5 * 2 + 1,
        NIGHTCLUB_SAFE_COLLECT = 2708832,
        NIGHTCLUB_INCOME_TOP5 = 262145 + 23750,
        NIGHTCLUB_INCOME_TOP100 = 262145 + 23769,
    },

    -- Kosatka
    KOSATKA = {
        REQUEST = 2733138 + 613,
        -- Kosatka Status (player stride: 468)
        STATUS = {
            PLAYER1 = 2658620,  -- 2658294 + 1 + (0 * 468) + 325 + 4
            PLAYER2 = 2659088,  -- 2658294 + 1 + (1 * 468) + 325 + 4
            PLAYER3 = 2659556,  -- 2658294 + 1 + (2 * 468) + 325 + 4
            PLAYER4 = 2660024,  -- 2658294 + 1 + (3 * 468) + 325 + 4
        },
    },

    -- Session
    SESSION = {
        TYPE = 1575044,
        SWITCH = 1574589,
        QUIT = 1574589 + 2,
    },
}

-- -------------------------------------------------------------------------
-- [Local Variable Offsets]
-- -------------------------------------------------------------------------

heist.LOCALS = {
    -- Launcher
    LAUNCHER = {
        STATUS = 20056 + 34,
        PLAYER_COUNT = 20056 + 15,
        TIMER = 20297,
    },

    -- fm_mission_controller (Old)
    MISSION_OLD = {
        -- Generic Skip
        SKIP_OLD = 20395 + 2,
        -- Casino Heist
        FINGERPRINT_HACK = 54042,
        KEYPAD_HACK = 55108,
        VAULT_DRILL_BASE = 10551,        -- Base for drill calculations
        VAULT_DRILL_1 = 10551 + 7,
        VAULT_DRILL_2 = 10551 + 37,
        AUTOGRABBER = 10697,
        AUTOGRABBER_SPEED = 10697 + 14,
        -- Generic Finish
        FINISH_OLD_STEP1 = 20395 + 1062,
        FINISH_OLD_STEP2 = 20395 + 1232 + 1,
        FINISH_OLD_STEP3 = 20395 + 1,
        -- Apartment Heist Finish
        APARTMENT_FINISH_STEP1 = 20395,
        APARTMENT_FINISH_STEP2 = 20395 + 1062,
        APARTMENT_FINISH_STEP3 = 20395 + 1740 + 1,
        APARTMENT_FINISH_STEP4 = 20395 + 2686,
        APARTMENT_FINISH_STEP5 = 29016 + 1,
        APARTMENT_FINISH_STEP6 = 32472 + 1 + 68,
        -- Doomsday Heist
        DATA_HACK = 1541,
        DOOMSDAY_HACK = 1298 + 135,
        DOOMSDAY_FINISH_STEP1 = 20395,
        DOOMSDAY_FINISH_STEP2 = 20395 + 1740 + 1,
        DOOMSDAY_FINISH_STEP3 = 29016 + 1,
        DOOMSDAY_FINISH_STEP4 = 32472 + 1 + 68,
        DOOMSDAY_FINISH_STEP5 = 32472 + 97,
        -- Classic Heist
        FLEECA_HACK = 12223 + 24,
        FLEECA_DRILL = 10511 + 11,
        PACIFIC_HACK = 10217,
    },

    -- fm_mission_controller_2020 (New)
    MISSION_NEW = {
        -- Generic Skip
        SKIP_NEW = 56223 + 2,
        -- Cayo Perico
        FINGERPRINT_HACK = 26486,
        PLASMA_CUTTER = 32589 + 3,
        DRAINAGE_PIPE = 31349,
        -- Generic Finish
        FINISH_NEW_STEP1 = 56223 + 1589,
        FINISH_NEW_STEP2 = 56223 + 1776 + 1,
        FINISH_NEW_STEP3 = 56223 + 1,
        -- Cayo Perico Finish
        CAYO_FINISH_STEP1 = 56223,
        CAYO_FINISH_STEP2 = 56223 + 1776 + 1,
        -- Agency Finish
        AGENCY_FINISH_STEP1 = 56223 + 1,
        AGENCY_FINISH_STEP2 = 56223 + 1776 + 1,
        -- Auto Shop Finish
        AUTOSHOP_FINISH_STEP1 = 56223 + 1,
        AUTOSHOP_FINISH_STEP2 = 56223 + 1776 + 1,
    },

    -- Cayo Island Heist
    ISLAND_HEIST = {
        VOLTLAB_TARGET = 793,
        VOLTLAB_CURRENT = 794,
        VOLTLAB_STATE = 795,
        VOLTLAB_COMPLETE = 10166 + 24,
    },

    -- Planning Scripts
    PLANNING = {
        ISLAND = 1570,
        CASINO = 212,
        CASINO_SILENT = 210,
        GANG_OPS = 211,
        TUNER = 408,
        SALVAGE = 537,
        SALVAGE_FORCE = 418,
    },

    -- Security Contract
    SECURITY_CONTRACT = {
        TIMER = 1858,
    },

    -- Salvage Yard Missions
    SALVAGE = {
        CARGO_STEP1 = 7187 + 1,
        CARGO_STEP2 = 7332 + 1249,
        POLICE_STEP1 = 9013 + 1,
        POLICE_STEP2 = 9146 + 1305,
        ARENA_STEP1 = 7914 + 1,
        ARENA_STEP2 = 8034 + 1314,
        CASINO_STEP1 = 9193 + 1,
        CASINO_STEP2 = 9330 + 1258,
        SUBMARINE_STEP1 = 6220 + 1,
        SUBMARINE_STEP2 = 6358 + 1159,
    },

    -- Cluckin Bell Hacks
    CLUCKIN = {
        CIRCUIT_HACK = 62,
        WORD_HACK = 106,
    },

    -- Casino Games
    CASINO_GAMES = {
        LUCKY_WHEEL_WIN = 304 + 14,
        LUCKY_WHEEL_PRIZE = 304 + 45,
    },

    -- Nightclub
    NIGHTCLUB = {
        SAFE_TYPE = 208 + 32 + 2,
        SAFE_COLLECT = 208 + 32 + 19 + 1,
    },
}

-- -------------------------------------------------------------------------
-- [Stat Names] (without MP0_/MP1_ prefix)
-- -------------------------------------------------------------------------

heist.STATS = {
    -- Agency
    AGENCY = {
        STORY_BS = "FIXER_STORY_BS",
        STORY_STRAND = "FIXER_STORY_STRAND",
        GENERAL_BS = "FIXER_GENERAL_BS",
        COMPLETED_BS = "FIXER_COMPLETED_BS",
        STORY_COOLDOWN = "FIXER_STORY_COOLDOWN_POSIX",
        SECURITY_COOLDOWN = "FIXER_SECURITY_CONTRACT_COOLDOWN_TIME",
        PAYPHONE_COOLDOWN = "REQUEST_FRANKLIN_PAYPHONE_HIT_COOLDOWN",
    },

    -- Auto Shop
    AUTOSHOP = {
        CURRENT = "TUNER_CURRENT",
        GEN_BS = "TUNER_GEN_BS",
    },

    -- Cayo Perico
    CAYO = {
        PROGRESS = "H4_PROGRESS",
        MISSIONS = "H4_MISSIONS",
        WEAPONS = "H4CNF_WEAPONS",
        TARGET = "H4CNF_TARGET",
        BS_GEN = "H4CNF_BS_GEN",
        BS_ENTR = "H4CNF_BS_ENTR",
        BS_ABIL = "H4CNF_BS_ABIL",
        APPROACH = "H4CNF_APPROACH",
        PLAYTHROUGH = "H4_PLAYTHROUGH_STATUS",
        -- Loot
        LOOT_CASH_C = "H4LOOT_CASH_C",
        LOOT_WEED_C = "H4LOOT_WEED_C",
        LOOT_COKE_C = "H4LOOT_COKE_C",
        LOOT_GOLD_C = "H4LOOT_GOLD_C",
        LOOT_CASH_I = "H4LOOT_CASH_I",
        LOOT_WEED_I = "H4LOOT_WEED_I",
        LOOT_COKE_I = "H4LOOT_COKE_I",
        LOOT_GOLD_I = "H4LOOT_GOLD_I",
        LOOT_PAINT = "H4LOOT_PAINT",
        -- Values
        LOOT_CASH_V = "H4LOOT_CASH_V",
        LOOT_WEED_V = "H4LOOT_WEED_V",
        LOOT_COKE_V = "H4LOOT_COKE_V",
        LOOT_GOLD_V = "H4LOOT_GOLD_V",
        LOOT_PAINT_V = "H4LOOT_PAINT_V",
        -- Scoped
        LOOT_CASH_C_SCOPED = "H4LOOT_CASH_C_SCOPED",
        LOOT_WEED_C_SCOPED = "H4LOOT_WEED_C_SCOPED",
        LOOT_COKE_C_SCOPED = "H4LOOT_COKE_C_SCOPED",
        LOOT_GOLD_C_SCOPED = "H4LOOT_GOLD_C_SCOPED",
        LOOT_CASH_I_SCOPED = "H4LOOT_CASH_I_SCOPED",
        LOOT_WEED_I_SCOPED = "H4LOOT_WEED_I_SCOPED",
        LOOT_COKE_I_SCOPED = "H4LOOT_COKE_I_SCOPED",
        LOOT_GOLD_I_SCOPED = "H4LOOT_GOLD_I_SCOPED",
        LOOT_PAINT_SCOPED = "H4LOOT_PAINT_SCOPED",
        -- Preps
        UNIFORM = "H4CNF_UNIFORM",
        GRAPPEL = "H4CNF_GRAPPEL",
        TROJAN = "H4CNF_TROJAN",
        WEP_DISRP = "H4CNF_WEP_DISRP",
        ARM_DISRP = "H4CNF_ARM_DISRP",
        HEL_DISRP = "H4CNF_HEL_DISRP",
        -- Cooldown
        TARGET_POSIX = "H4_TARGET_POSIX",
        COOLDOWN = "H4_COOLDOWN",
        COOLDOWN_HARD = "H4_COOLDOWN_HARD",
    },

    -- Casino
    CASINO = {
        APPROACH = "H3OPT_APPROACH",
        OPT_APPROACH = "H3OPT_APPROACH",  -- Alias for compatibility
        TARGET = "H3OPT_TARGET",
        MASKS = "H3OPT_MASKS",
        WEAPS = "H3OPT_WEAPS",
        VEHS = "H3OPT_VEHS",
        POI = "H3OPT_POI",
        ACCESSPOINTS = "H3OPT_ACCESSPOINTS",
        CREWWEAP = "H3OPT_CREWWEAP",
        CREWDRIVER = "H3OPT_CREWDRIVER",
        CREWHACKER = "H3OPT_CREWHACKER",
        DISRUPTSHIP = "H3OPT_DISRUPTSHIP",
        BODYARMORLVL = "H3OPT_BODYARMORLVL",
        KEYLEVELS = "H3OPT_KEYLEVELS",
        BITSET0 = "H3OPT_BITSET0",
        BITSET1 = "H3OPT_BITSET1",
        HARD_APPROACH = "H3_HARD_APPROACH",
        LAST_APPROACH = "H3_LAST_APPROACH",
        HEIST_FLOW = "CAS_HEIST_FLOW",
        HEIST_NOTS = "CAS_HEIST_NOTS",
        BOARD_DIALOGUE0 = "H3_BOARD_DIALOGUE0",
        BOARD_DIALOGUE1 = "H3_BOARD_DIALOGUE1",
        BOARD_DIALOGUE2 = "H3_BOARD_DIALOGUE2",
        COMPLETEDPOSIX = "H3_COMPLETEDPOSIX",
        COOLDOWN = "MPPLY_H3_COOLDOWN",
    },

    -- Doomsday
    DOOMSDAY = {
        FLOW_MISSION_PROG = "GANGOPS_FLOW_MISSION_PROG",
        HEIST_STATUS = "GANGOPS_HEIST_STATUS",
        FLOW_NOTIFICATIONS = "GANGOPS_FLOW_NOTIFICATIONS",
    },

    -- Apartment / Classic
    APARTMENT = {
        PLANNING_STAGE = "HEIST_PLANNING_STAGE",
        -- Unlock All Jobs stats
        HEIST_SAVED_STRAND_0 = "HEIST_SAVED_STRAND_0",
        HEIST_SAVED_STRAND_0_L = "HEIST_SAVED_STRAND_0_L",
        HEIST_SAVED_STRAND_1 = "HEIST_SAVED_STRAND_1",
        HEIST_SAVED_STRAND_1_L = "HEIST_SAVED_STRAND_1_L",
        HEIST_SAVED_STRAND_2 = "HEIST_SAVED_STRAND_2",
        HEIST_SAVED_STRAND_2_L = "HEIST_SAVED_STRAND_2_L",
        HEIST_SAVED_STRAND_3 = "HEIST_SAVED_STRAND_3",
        HEIST_SAVED_STRAND_3_L = "HEIST_SAVED_STRAND_3_L",
        HEIST_SAVED_STRAND_4 = "HEIST_SAVED_STRAND_4",
        HEIST_SAVED_STRAND_4_L = "HEIST_SAVED_STRAND_4_L",
    },

    -- Classic Heist Bonuses
    CLASSIC_BONUS = {
        FLOW_ORDER = "MPPLY_HEISTFLOWORDERPROGRESS",
        AWD_ORDER = "MPPLY_AWD_HST_ORDER",
        TEAM_PROGRESS = "MPPLY_HEISTTEAMPROGRESSBITSET",
        AWD_TEAM = "MPPLY_AWD_HST_SAME_TEAM",
        NO_DEATH = "MPPLY_HEISTNODEATHPROGREITSET",
        AWD_ULT = "MPPLY_AWD_HST_ULT_CHAL",
    },

    -- Salvage Yard / Cluckin Bell
    SALVAGE = {
        INST_PROG = "SALV23_INST_PROG",
        GEN_BS = "SALV23_GEN_BS",
        SCOPE_BS = "SALV23_SCOPE_BS",
        FM_PROG = "SALV23_FM_PROG",
        CFR_COOLDOWN = "SALV23_CFR_COOLDOWN",
    },
}

-- -------------------------------------------------------------------------
-- [UI Option Lists] - {display_name, value}
-- -------------------------------------------------------------------------

heist.OPTIONS = {
    -- Agency Contracts
    AGENCY_CONTRACTS = {
        { "None", 3 },
        { "Nightclub", 4 },
        { "Marina", 12 },
        { "Nightlife Leak", 28 },
        { "Country Club", 60 },
        { "Guest List", 123 },
        { "High Society Leak", 254 },
        { "Davis", 508 },
        { "Ballas", 1020 },
        { "South Central Leak", 2044 },
        { "Studio Time", 2045 },
        { "Don't F With Dre", 4095 },
    },

    -- Auto Shop Contracts
    AUTOSHOP_CONTRACTS = {
        { "None", -1 },
        { "Union Depository", 0 },
        { "Superdollar Deal", 1 },
        { "Bank Contract", 2 },
        { "ECU Job", 3 },
        { "Prison Contract", 4 },
        { "Agency Deal", 5 },
        { "Lost Contract", 6 },
        { "Data Contract", 7 },
    },

    -- Cayo Difficulty
    CAYO_DIFFICULTY = {
        { "Normal", 126823 },
        { "Hard", 131055 },
    },

    -- Cayo Approach
    CAYO_APPROACH = {
        { "Kosatka", 65283 },
        { "Alkonost", 65413 },
        { "Velum", 65289 },
        { "Stealth Annihilator", 65425 },
        { "Patrol Boat", 65313 },
        { "Longfin", 65345 },
        { "All Ways", 65535 },
    },

    -- Cayo Loadout
    CAYO_LOADOUT = {
        { "Aggressor", 1 },
        { "Conspirator", 2 },
        { "Crackshot", 3 },
        { "Saboteur", 4 },
        { "Marksman", 5 },
    },

    -- Cayo Primary Target
    CAYO_TARGET = {
        { "Tequila", 0 },
        { "Ruby Necklace", 1 },
        { "Bearer Bonds", 2 },
        { "Pink Diamond", 3 },
        { "Madrazo Files", 4 },
        { "Panther Statue", 5 },
    },

    -- Cayo Secondary Target
    CAYO_SECONDARY = {
        { "None", "NONE" },
        { "Cash", "CASH" },
        { "Weed", "WEED" },
        { "Coke", "COKE" },
        { "Gold", "GOLD" },
    },

    -- Cayo Compound Amount
    CAYO_COMPOUND_AMOUNT = {
        { "Empty", 0 },
        { "1", 128 },
        { "2", 64 },
        { "3", 196 },
        { "4", 204 },
        { "5", 220 },
        { "6", 252 },
        { "7", 253 },
        { "Full", 255 },
    },

    -- Cayo Island Amount
    CAYO_ISLAND_AMOUNT = {
        { "Empty", 0 },
        { "Full", 16777215 },
    },

    -- Cayo Arts Amount
    CAYO_ARTS_AMOUNT = {
        { "Empty", 0 },
        { "1", 64 },
        { "2", 96 },
        { "3", 112 },
        { "4", 120 },
        { "5", 122 },
        { "6", 126 },
        { "Full", 127 },
    },

    -- Doomsday Acts
    DOOMSDAY_ACTS = {
        { "Act I: The Data Breaches", 1 },
        { "Act II: The Bogdan Problem", 2 },
        { "Act III: The Doomsday Scenario", 3 },
    },

    -- Doomsday Presets
    DOOMSDAY_PRESETS = {
        ACT1 = { flow = 503, status = -229383, notifications = 1557 },
        ACT2 = { flow = 240, status = -229378, notifications = 1557 },
        ACT3 = { flow = 16368, status = -229380, notifications = 1557 },
        RESET = { flow = 503, status = 0, notifications = 1557 },
    },

    -- Casino Approaches (BITSET values)
    CASINO_PRESETS = {
        SILENT = {
            APPROACH = 1,
            BITSET0 = 262270,
            BITSET1 = 127,
        },
        BIGCON = {
            APPROACH = 2,
            BITSET0 = 524118,
            BITSET1 = 159,
        },
        AGGRESSIVE = {
            APPROACH = 3,
            BITSET0 = 3670102,
            BITSET1 = 799,
        },
    },

    -- Salvage Yard Options
    SALVAGE_ROBBERIES = {
        { "Cargo Ship", 0 },
        { "Gangbanger", 1 },
        { "Duggan", 2 },
        { "Podium", 3 },
        { "McTony", 4 },
    },

    SALVAGE_VEHICLES = {
        { "LM87", 1 },
        { "Cinquemila", 2 },
        { "Virtue", 3 },
        { "Pipistrello", 4 },
        { "Brigham", 5 },
        { "Vigero ZX", 6 },
        { "SM722", 7 },
        { "Panthere", 8 },
        { "Greenwood", 9 },
        { "Baller ST", 10 },
        { "Astron", 11 },
        { "Deity", 12 },
        { "Jubilee", 13 },
        { "Granger 3600LX", 14 },
        { "Patriot Mil-Spec", 15 },
        { "Champion", 16 },
        { "Buffalo STX", 17 },
        { "Comet S2", 18 },
        { "Shinobi", 19 },
        { "Ignus", 20 },
        { "Zeno", 21 },
        { "Reever", 22 },
        { "Comet S2 Cabrio", 23 },
        { "Patriot Mil-Spec 2", 24 },
        { "Omnis e-GT", 25 },
        { "Neon", 26 },
        { "S95", 27 },
        { "Iwagen", 28 },
        { "Astron Custom", 29 },
        { "Cyclone II", 30 },
        { "Weaponized Ignus", 31 },
        { "Stirling GT", 32 },
        { "Torero XO", 33 },
        { "Turismo Omaggio", 34 },
        { "LM87 2", 35 },
        { "R300", 36 },
        { "R300 2", 37 },
        { "Turismo Classic", 38 },
        { "Turismo Classic 2", 39 },
        { "Corsita", 40 },
        { "10F", 41 },
        { "10F Widebody", 42 },
        { "Kanjali", 43 },
        { "Ruiner ZZ-8", 44 },
        { "Draugur", 45 },
        { "Greenwood 2", 46 },
        { "Rhinehart", 47 },
        { "Brioso 300", 48 },
        { "Brioso 300 Widebody", 49 },
        { "Sentinel Classic Widebody", 50 },
    },

    SALVAGE_MODIFICATIONS = {
        { "Version 1", 0 },
        { "Version 2", 1 },
        { "Version 3", 2 },
        { "Version 4", 3 },
        { "Version 5", 4 },
    },

    SALVAGE_KEEPS = {
        { "Can't Claim", 0 },
        { "Can Claim", 1 },
    },
}

-- -------------------------------------------------------------------------
-- [Tunable Names]
-- -------------------------------------------------------------------------

heist.TUNABLES = {
    -- Apartment / Classic Heist Root ID Hashes
    APARTMENT = {
        ROOT_ID_HASH_FLEECA = "ROOT_ID_HASH_THE_FLECCA_JOB",
        ROOT_ID_HASH_PRISON = "ROOT_ID_HASH_THE_PRISON_BREAK",
        ROOT_ID_HASH_HUMANE = "ROOT_ID_HASH_THE_HUMANE_LABS_RAID",
        ROOT_ID_HASH_SERIES_A = "ROOT_ID_HASH_SERIES_A_FUNDING",
        ROOT_ID_HASH_PACIFIC = "ROOT_ID_HASH_THE_PACIFIC_STANDARD_JOB",
    },

    AUTOSHOP_PAYOUT = {
        "TUNER_ROBBERY_LEADER_CASH_REWARD0",
        "TUNER_ROBBERY_LEADER_CASH_REWARD1",
        "TUNER_ROBBERY_LEADER_CASH_REWARD2",
        "TUNER_ROBBERY_LEADER_CASH_REWARD3",
        "TUNER_ROBBERY_LEADER_CASH_REWARD4",
        "TUNER_ROBBERY_LEADER_CASH_REWARD5",
        "TUNER_ROBBERY_LEADER_CASH_REWARD6",
        "TUNER_ROBBERY_LEADER_CASH_REWARD7",
    },
    CLASSIC_HEIST_IDS = {
        FLEECA = "ROOT_ID_HASH_THE_FLECCA_JOB",
        PRISON = "ROOT_ID_HASH_THE_PRISON_BREAK",
        HUMANE = "ROOT_ID_HASH_THE_HUMANE_LABS_RAID",
        SERIES_A = "ROOT_ID_HASH_SERIES_A_FUNDING",
        PACIFIC = "ROOT_ID_HASH_THE_PACIFIC_STANDARD_JOB",
    },
    -- Agency Cooldowns
    AGENCY = {
        STORY_COOLDOWN = "FIXER_STORY_COMPLETION_COOLDOWN",
        SECURITY_COOLDOWN = "FIXER_SECURITY_CONTRACT_COOLDOWN",
        PAYPHONE_COOLDOWN = "PAYPHONE_HIT_COOLDOWN_TIME",
        PAYOUT = 262145 + 31249,  -- Global tunable
    },
    -- Auto Shop Cooldown
    AUTOSHOP = {
        COOLDOWN = "TUNER_ROBBERY_COOLDOWN",
    },
    -- Cayo Perico
    CAYO = {
        BAG_CAPACITY = "IH_LOOT_BAG_MAX_CAPACITY",
        PAVEL_CUT = "IH_FENCING_FEE_DIVIDE",
        FENCE_FEE = "IH_DEDUCTION_FENCING_FEE",
    },
    -- Casino
    CASINO = {
        BAG_LIMIT = "CH_LOOT_BAG_LIMIT",
    },
    SALVAGE = {
        -- Robbery slots
        SLOT1_ROBBERY_TYPE = 1152433341,
        SLOT2_ROBBERY_TYPE = 852564222,
        SLOT3_ROBBERY_TYPE = 552662330,
        SETUP_PRICE = 71522671,
        -- Vehicle slots
        SLOT1_VEHICLE_TYPE = -1012732012,
        SLOT1_VEHICLE_VALUE = -1699398139,
        SLOT1_KEEP = -1700733442,
        SLOT2_VEHICLE_TYPE = 1366330161,
        SLOT2_VEHICLE_VALUE = -1997104504,
        SLOT2_KEEP = -1547046832,
        SLOT3_VEHICLE_TYPE = 1806057372,
        SLOT3_VEHICLE_VALUE = -1704051341,
        SLOT3_KEEP = 1830093543,
        -- Misc
        VALUE_MULTIPLIER = 1601153005,
        -- Cooldowns
        COOLDOWN_ROBBERY = "SALV23_VEH_ROB_COOLDOWN_TIME",
        COOLDOWN_CFR = "SALV23_CFR_COOLDOWN_TIME",
    },
}

-- -------------------------------------------------------------------------
-- [Default Values]
-- -------------------------------------------------------------------------

heist.DEFAULTS = {
    CAYO = {
        CASH_VALUE = 83250,
        WEED_VALUE = 135000,
        COKE_VALUE = 202500,
        GOLD_VALUE = 333333,
        ARTS_VALUE = 180000,
    },

    AUTOSHOP = {
        MAX_PAYOUT = 2200000,
        DEFAULT_PAYOUT = 1000000,
    },

    AGENCY = {
        MAX_PAYOUT = 2500000,
    },

    CAYO_COOLDOWN = {
        SOLO = 1659643454,
        TEAM = 1659429119,
    },
}

-- -------------------------------------------------------------------------
-- [Constant Values for Operations]
-- -------------------------------------------------------------------------

heist.VALUES = {
    -- Planning board reload trigger value
    BOARD_RELOAD = 2,
    GANG_OPS_RELOAD = 6,  -- Gang Ops uses different value

    -- Hack bypass values (set to local to skip hack)
    HACK_BYPASS = {
        FINGERPRINT = 5,     -- Casino/Cayo fingerprint hack
        KEYPAD = 5,          -- Casino keypad
        VOLTLAB = 5,         -- Cayo island fingerprint
        FLEECA = 7,          -- Apartment Fleeca hack
        PACIFIC = 9,         -- Apartment Pacific Standard hack
        DATA = 2,            -- Doomsday Data Breaches hack
        DOOMSDAY = 3,        -- Doomsday hacks
        DRAINAGE = 6,        -- Cayo drainage pipe
        PLASMA_CUTTER = 100.0,  -- Cayo plasma cutter (float)
        FLEECA_DRILL = 100.0,   -- Apartment Fleeca drill (float)
    },

    -- Instant finish values
    FINISH = {
        CAYO_STEP1 = 9,
        CAYO_STEP2 = 50,
        CASINO_AGGRESSIVE_STEP1 = 12,
        CASINO_STEP4_MONEY = 10000000,
        APARTMENT_STEP1 = 12,        -- Non-Pacific heists
        APARTMENT_STEP2 = 5,
        APARTMENT_STEP3 = 80,
        APARTMENT_STEP4_MONEY = 10000000,
        APARTMENT_STEP5 = 99999,
        APARTMENT_STEP6 = 99999,
        APARTMENT_STEP4_ALT = 99999,  -- Non-Pacific STEP4 value
        DOOMSDAY_STEP1 = 12,
        DOOMSDAY_STEP2 = 150,
        DOOMSDAY_STEP3 = 99999,
        DOOMSDAY_STEP4 = 99999,
        DOOMSDAY_STEP5 = 80,
        AGENCY_STEP1 = 51338752,
        AGENCY_STEP2 = 50,
        AUTOSHOP_STEP1 = 51338977,
        AUTOSHOP_STEP2 = 101,
    },

    -- Teleport/Force ready values
    BOARD_CLASSIC = 22,
    READY_STATE_APARTMENT = 6,
    READY_STATE_HEIST = 1,

    -- Prep completion values
    CAYO_PREP = {
        BS_ENTR = 63,
        BS_ABIL = 63,
        TROJAN = 5,
        DISRUPT = 3,
    },

    -- Strand completion value
    STRAND_COMPLETE = 5,

    -- Max capacity values
    MAX_CAPACITY = 99999,

    -- Player count offset calculation constants
    PLAYER_COUNT_OFFSET = {
        BASE = 4,
        MULTIPLIER = 95,
        FINAL_OFFSET = 75,
    },

    -- Salvage Yard finish values
    SALVAGE_FINISH = {
        STEP1 = 4,
        STEP2 = 5,
    },
}

-- -------------------------------------------------------------------------
-- [Helper: Build dropdown options for UI]
-- -------------------------------------------------------------------------

--- Convert option list to UI-friendly format
---@param options table List of {name, value} pairs
---@return table names List of display names
---@return table values List of values
function heist.build_options(options)
    local names = {}
    local values = {}
    for i, opt in ipairs(options) do
        names[i] = opt[1]
        values[i] = opt[2]
    end
    return names, values
end

--- Get value from option by index
---@param options table Option list
---@param index integer 1-based index
---@return any value Option value
function heist.get_option_value(options, index)
    if options[index] then
        return options[index][2]
    end
    return options[1] and options[1][2] or 0
end

--- Find index by value in option list
---@param options table Option list
---@param value any Value to find
---@return integer index 1-based index (default 1)
function heist.find_option_index(options, value)
    for i, opt in ipairs(options) do
        if opt[2] == value then
            return i
        end
    end
    return 1
end

return heist
